using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class WebMaster_UserControls_ucMainMenu : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        InitMainMenu(tblMainMenu);
    }

    private void InitMainMenu(Table table)
    {
        string sDivCss = "horizontalcssmenu";
        string sMenu = "", sEvent = "", sAbout = "", sOther = "", sProject = "", sContact = "", sInvest = "", sPartner = "";
        string myMenu = "", about = "", system = "", product = "";
        if (Session["UserRole"] != null)
        {
            system += "<ul>";
            system += MakeItem(GlobalClassBE.PageName.WebInfo, GlobalClassBE.PageName.WebInfoTitle);
            system += MakeItem(GlobalClassBE.PageName.Online, GlobalClassBE.PageName.OnlineTitle);
            //system += MakeItem(GlobalClassBE.PageName.Unite, GlobalClassBE.PageName.UniteTitle);
            system += MakeItem(GlobalClassBE.PageName.Location, GlobalClassBE.PageName.LocationTitle);
            system += MakeItem(GlobalClassBE.PageName.State, GlobalClassBE.PageName.StateTitle);
            //system += MakeItem(GlobalClassBE.PageName.Statics + "?act=edit&id=02", "Gi&#7899;i thi&#7879;u");
            //system += MakeItem(GlobalClassBE.PageName.Statics + "?act=edit&id=08", "Th&#244;ng tin li&#234;n h&#7879;");
            //system += MakeItem(GlobalClassBE.PageName.Statics + "?act=edit&id=10", "Gi&#7899;i thi&#7879;u khu c&#244;ng nghi&#7879;p");
            system += "</ul>";

            product += "<ul>";
            product += MakeItem(GlobalClassBE.PageName.Comment, GlobalClassBE.PageName.CommentTitle);
            product += MakeItem(GlobalClassBE.PageName.Product, GlobalClassBE.PageName.ProductTitle);
            product += MakeItem(GlobalClassBE.PageName.ProductCategory, GlobalClassBE.PageName.ProductCategoryTitle);
            product += "</ul>";

            GssBL.BLLogon.UserRole enumRole = (GssBL.BLLogon.UserRole)Session["UserRole"];
            if (enumRole == GssBL.BLLogon.UserRole.WebMaster)
            {
                myMenu += "<div class='" + sDivCss + "'>";
                myMenu += "<ul id='cssmenu1'>";
                myMenu += MakeItemRoot(GlobalClassBE.PageName.Infor, "medium", GlobalClassBE.PageName.InforTitle, sAbout);
                myMenu += MakeItemRoot(GlobalClassBE.PageName.Product, "medium", "S&#7843;n ph&#7849;m", product);
                myMenu += MakeItem(GlobalClassBE.PageName.Shop, "small", GlobalClassBE.PageName.ShopTitle);
                myMenu += MakeItem(GlobalClassBE.PageName.FashionNews, "medium", GlobalClassBE.PageName.FashionNewsTitle);
                myMenu += MakeItem(GlobalClassBE.PageName.Collection, "medium", GlobalClassBE.PageName.CollectionTitle);
                myMenu += MakeItem(GlobalClassBE.PageName.Advertise, "big", GlobalClassBE.PageName.AdvertiseTitle);
                //myMenu += MakeItem(GlobalClassBE.PageName.Contact, "medium", GlobalClassBE.PageName.ContactTitle);
                myMenu += MakeItemRoot("#", "medium", "H&#7879; th&#7889;ng", system);
                myMenu += "</ul>";
                myMenu += "</div>";
            }
            else if (enumRole == GssBL.BLLogon.UserRole.WebEditor)
            {
                myMenu += "<div class='" + sDivCss + "'>";
                myMenu += "<ul id='cssmenu1'>";
                myMenu += MakeItem(GlobalClassBE.PageName.FashionNews, "medium", GlobalClassBE.PageName.FashionNewsTitle);
                myMenu += MakeItem(GlobalClassBE.PageName.Collection, "medium", GlobalClassBE.PageName.CollectionTitle);
                myMenu += "</ul>";
                myMenu += "</div>";
            }
        }
        /********************************************/
        TableCell cell = new TableCell();
        cell.Controls.Add(new LiteralControl(myMenu));
        TableRow row = new TableRow();
        row.Cells.Add(cell);
        table.Rows.Add(row);
    }

    private string MakeItem(string target, string caption)
    {
        string sItem = "<li><a href='{0}'>{1}</a></li>";

        return String.Format(sItem, target, caption);
    }

    private string MakeItem(string target, string name, string caption)
    {
        string sItem = "<li><a id='{2}' href='{0}'>{1}</a></li>";

        return String.Format(sItem, target, caption, name);
    }

    private string MakeItemRoot(string target, string name, string caption, string listItem)
    {
        string sItem = "<li><a id='{3}' href='{0}'>{1}</a>{2}</li>";

        return String.Format(sItem, target, caption, listItem, name);
    }

    private string MakeItemRoot(string target, string caption, string listItem)
    {
        string sItem = "<li><a href='{0}'>{1}</a>{2}</li>";

        return String.Format(sItem, target, caption, listItem);
    }
}
